<?php
/**
 * 描述：资讯-访谈首页。
 * @final
 */
final class Exec_News_Interview_Index
{
    public function __Construct()
    {
        #获取数据-本期嘉宾
        $data=DB::GetRows('select * from interview where M_IsCurrent=TRUE order by ID desc limit 0,1');
        if($data)
        {
            $data=$data[0];
            $data['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$data['ThumbnailPath'];
        }
        View::Assign('Current',$data);

        #获取数据-访谈
        $data=DB::GetRows('select * from interview order by M_IsTop desc,M_IsTop_Datetime desc,ID desc limit 0,4');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Interview',$data);

        #获取数据-最新访谈
        $data=DB::GetRows('select * from interview order by ID desc limit 0,10');
        foreach($data as &$row)
        {
            if((time()-strtotime($row['Datetime']))/3600/24<3)
                $row['IsNew']='TRUE';
            else
                $row['IsNew']='FALSE';
        }
        View::Assign('Interview_Latest',$data);

        #获取数据-人物排行榜
        $data=DB::GetRows('select * from interview order by VisitsCount desc,ID desc limit 0,10');
        View::Assign('Interview_Ranking',$data);

        #获取数据-明星企业
        $data=DB::GetRows('select * from enterprise_star order by ID asc limit 0,5');
        foreach($data as &$row)
        {
            $row['PicturePath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['PicturePath'];
        }
        View::Assign('Enterprise_Star',$data);

        #获取数据-企业之窗
        $data=DB::GetRows('select * from enterprise order by M_IsTop desc,M_IsTop_Datetime desc,ID desc limit 0,4');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Enterprise',$data);
        
        #获取数据-企业排行榜
        $data=DB::GetRows('select * from enterprise order by VisitsCount desc,ID desc limit 0,10');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Enterprise_Ranking',$data);

        #渲染输出
        View::Display('news/interview/index.tpl');        
    }
}
?>